package com.business.api.official.toursism.websitehotel.manager.impl;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.business.api.official.toursism.websitehotel.manager.WebsiteHotelApiManager;
import com.business.api.official.toursism.websitehotel.mapper.WebsiteHotelApiMapper;
import com.business.api.official.toursism.websitehotel.vo.WebsiteHotelApiBriefListVO;
import com.business.api.official.toursism.websitehotel.vo.WebsiteHotelApiBriefVO;
import com.business.api.official.toursism.websitehotel.vo.WebsiteHotelApiDetailListVO;
import com.business.api.official.toursism.websitehotel.vo.WebsiteHotelApiDetailVO;
import com.business.api.official.toursism.websitehotel.vo.data.WebsiteHotelApiBriefData;
import com.business.api.official.toursism.websitehotel.vo.data.WebsiteHotelApiDetailData;
import com.business.system.official.toursism.websitehotel.entity.WebsiteHotel;
import com.business.system.official.toursism.websitehotel.manager.WebsiteHotelManager;
import com.seed.core.exception.ManagerException;
import com.seed.core.pojo.manager.impl.SeedApiManagerImpl;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.ArrayList;
import java.util.List;

/**
 * @description 乌镇酒店
 * @author CodeGenerator
 * @date   2025-01-25
 * @version V1.0
 */
@Slf4j
@Service("websiteHotelApiManager")
@Transactional(rollbackFor = ManagerException.class)
public class WebsiteHotelApiManagerImpl extends SeedApiManagerImpl<WebsiteHotelApiMapper, WebsiteHotel> implements WebsiteHotelApiManager {
    @Autowired
    private WebsiteHotelManager systemManager;

    /**
     * 根据id获取详情VO data
     *
     * @param websiteHotelId 对象id
     * @return 详情VO data对象
     * @throws ManagerException 通用层异常
     */
    @Override
    public WebsiteHotelApiDetailData convertApiDetailData(String websiteHotelId) throws ManagerException {
        WebsiteHotel websiteHotel = this.getById(websiteHotelId);
        return this.convertApiDetailData(websiteHotel);
    }

    /**
     * 转换为VO对象
     *
     * @param websiteHotel model
     * @return VO对象
     * @throws ManagerException 通用层异常
     */
    @Override
    public WebsiteHotelApiDetailData convertApiDetailData(WebsiteHotel websiteHotel) throws ManagerException {
        WebsiteHotelApiDetailData websiteHotelApiDetailData = new WebsiteHotelApiDetailData();
        try {
            BeanUtils.copyProperties(websiteHotel, websiteHotelApiDetailData);
        } catch (Exception e) {
            throw new ManagerException(e, websiteHotel);
        }
        return websiteHotelApiDetailData;
    }

    /**
     * 根据id获取详情VO
     *
     * @param websiteHotelId 对象id
     * @return 详情VO对象
     * @throws ManagerException 通用层异常
     */
    @Override
    public WebsiteHotelApiDetailVO getApiDetailVO(String websiteHotelId) throws ManagerException {
        WebsiteHotelApiDetailData websiteHotelApiDetailData = this.convertApiDetailData(websiteHotelId);
        return new WebsiteHotelApiDetailVO(websiteHotelApiDetailData);
    }

    /**
     * 根据对象获取详情VO
     *
     * @param websiteHotel 对象
     * @return 详情VO对象
     * @throws ManagerException 通用层异常
     */
    @Override
    public WebsiteHotelApiDetailVO getApiDetailVO(WebsiteHotel websiteHotel) throws ManagerException {
        WebsiteHotelApiDetailData websiteHotelApiDetailData = this.convertApiDetailData(websiteHotel);
        return new WebsiteHotelApiDetailVO(websiteHotelApiDetailData);
    }

    /**
     * 根据对象ids获取详情VO data list
     *
     * @param ids 对象ids
     * @return 详情VO data list对象
     * @throws ManagerException 通用层异常
     */
    @Override
    public List<WebsiteHotelApiDetailData> getConvertApiDetailListVOByIds(List<String> ids) throws ManagerException {
        LambdaQueryWrapper<WebsiteHotel> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.in(WebsiteHotel::getId, ids);
        List<WebsiteHotel> websiteHotelList = this.list(queryWrapper);
        return this.listConvertApiDetailData(websiteHotelList);
    }

    /**
     * 根据查询条件获取详情VO data list
     *
     * @param queryWrapper 查询条件
     * @return 详情VO data list对象
     * @throws ManagerException 通用层异常
     */
    @Override
    public List<WebsiteHotelApiDetailData> listConvertApiDetailData(Wrapper<WebsiteHotel> queryWrapper) throws ManagerException {
        List<WebsiteHotel> websiteHotelList = this.list(queryWrapper);
        return this.listConvertApiDetailData(websiteHotelList);
    }

    /**
     * 转换为VO对象
     *
     * @param websiteHotelList model列表
     * @return VO对象列表
     * @throws ManagerException 通用层异常
     */
    @Override
    public List<WebsiteHotelApiDetailData> listConvertApiDetailData(List<WebsiteHotel> websiteHotelList) throws ManagerException {
        List<WebsiteHotelApiDetailData> websiteHotelApiDetailDataList = new ArrayList<>();
        for (WebsiteHotel websiteHotel : websiteHotelList) {
            websiteHotelApiDetailDataList.add(this.convertApiDetailData(websiteHotel));
        }
        return websiteHotelApiDetailDataList;
    }

    /**
     * 根据对象ids获取详情VO data list
     *
     * @param ids 对象ids
     * @return 详情VO data list对象
     * @throws ManagerException 通用层异常
     */
    @Override
    public WebsiteHotelApiDetailListVO getApiDetailListVOByIds(List<String> ids) throws ManagerException {
        return new WebsiteHotelApiDetailListVO(this.getConvertApiDetailListVOByIds(ids));
    }

    /**
     * 根据查询条件获取详情VO data list
     *
     * @param queryWrapper 查询条件
     * @return 详情VO data list对象
     * @throws ManagerException 通用层异常
     */
    @Override
    public WebsiteHotelApiDetailListVO getApiDetailListVO(Wrapper<WebsiteHotel> queryWrapper) throws ManagerException {
        return new WebsiteHotelApiDetailListVO(this.listConvertApiDetailData(queryWrapper));
    }

    /**
     * 根据对象list获取详情VO data list
     *
     * @param websiteHotelList 对象list
     * @return 详情VO data list对象
     * @throws ManagerException 通用层异常
     */
    @Override
    public WebsiteHotelApiDetailListVO getApiDetailListVO(List<WebsiteHotel> websiteHotelList) throws ManagerException {
        return new WebsiteHotelApiDetailListVO(this.listConvertApiDetailData(websiteHotelList));
    }

    /**
     * 根据id获取简略VO data
     *
     * @param websiteHotelId 对象id
     * @return 简略VO data对象
     * @throws ManagerException 通用层异常
     */
    @Override
    public WebsiteHotelApiBriefData convertApiBriefData(String websiteHotelId) throws ManagerException {
        WebsiteHotel websiteHotel = this.getById(websiteHotelId);
        return this.convertApiBriefData(websiteHotel);
    }

    /**
     * 转换为VO对象
     *
     * @param websiteHotel model
     * @return VO对象
     * @throws ManagerException 通用层异常
     */
    @Override
    public WebsiteHotelApiBriefData convertApiBriefData(WebsiteHotel websiteHotel) throws ManagerException {
        WebsiteHotelApiBriefData websiteHotelApiBriefData = new WebsiteHotelApiBriefData();
        try {
            BeanUtils.copyProperties(websiteHotel, websiteHotelApiBriefData);
        } catch (Exception e) {
            throw new ManagerException(e, websiteHotel);
        }
        return websiteHotelApiBriefData;
    }

    /**
     * 根据id获取简略VO
     *
     * @param websiteHotelId 对象id
     * @return 简略VO对象
     * @throws ManagerException 通用层异常
     */
    @Override
    public WebsiteHotelApiBriefVO getApiBriefVO(String websiteHotelId) throws ManagerException {
        WebsiteHotelApiBriefData websiteHotelApiBriefData = this.convertApiBriefData(websiteHotelId);
        return new WebsiteHotelApiBriefVO(websiteHotelApiBriefData);
    }

    /**
     * 根据对象获取简略VO
     *
     * @param websiteHotel 对象
     * @return 简略VO对象
     * @throws ManagerException 通用层异常
     */
    @Override
    public WebsiteHotelApiBriefVO getApiBriefVO(WebsiteHotel websiteHotel) throws ManagerException {
        WebsiteHotelApiBriefData websiteHotelApiBriefData = this.convertApiBriefData(websiteHotel);
        return new WebsiteHotelApiBriefVO(websiteHotelApiBriefData);
    }

    /**
     * 根据对象ids获取简略VO data list
     *
     * @param ids 对象ids
     * @return 简略VO data list对象
     * @throws ManagerException 通用层异常
     */
    @Override
    public List<WebsiteHotelApiBriefData> listConvertApiBriefDataByIds(List<String> ids) throws ManagerException {
        LambdaQueryWrapper<WebsiteHotel> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.in(WebsiteHotel::getId, ids);
        List<WebsiteHotel> websiteHotelList = this.list(queryWrapper);
        return this.listConvertApiBriefData(websiteHotelList);
    }

    /**
     * 根据查询条件获取简略VO data list
     *
     * @param queryWrapper 查询条件
     * @return 简略VO data list对象
     * @throws ManagerException 通用层异常
     */
    @Override
    public List<WebsiteHotelApiBriefData> listConvertApiBriefData(Wrapper<WebsiteHotel> queryWrapper) throws ManagerException {
        List<WebsiteHotel> websiteHotelList = this.list(queryWrapper);
        return this.listConvertApiBriefData(websiteHotelList);
    }

    /**
     * 转换为VO对象
     *
     * @param websiteHotelList model列表
     * @return VO对象列表
     * @throws ManagerException 通用层异常
     */
    @Override
    public List<WebsiteHotelApiBriefData> listConvertApiBriefData(List<WebsiteHotel> websiteHotelList) throws ManagerException {
        List<WebsiteHotelApiBriefData> websiteHotelApiBriefDataList = new ArrayList<>();
        for (WebsiteHotel websiteHotel : websiteHotelList) {
            websiteHotelApiBriefDataList.add(this.convertApiBriefData(websiteHotel));
        }
        return websiteHotelApiBriefDataList;
    }

    /**
     * 根据对象ids获取简略VO data list
     *
     * @param ids 对象ids
     * @return 简略VO data list对象
     * @throws ManagerException 通用层异常
     */
    @Override
    public WebsiteHotelApiBriefListVO getApiBriefListVOByIds(List<String> ids) throws ManagerException {
        LambdaQueryWrapper<WebsiteHotel> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.in(WebsiteHotel::getId, ids);
        List<WebsiteHotel> websiteHotelList = this.list(queryWrapper);
        return new WebsiteHotelApiBriefListVO(this.listConvertApiBriefData(websiteHotelList));
    }

    /**
     * 根据查询条件获取简略VO data list
     *
     * @param queryWrapper 查询条件
     * @return 简略VO data list对象
     * @throws ManagerException 通用层异常
     */
    @Override
    public WebsiteHotelApiBriefListVO getApiBriefListVO(Wrapper<WebsiteHotel> queryWrapper) throws ManagerException {
        List<WebsiteHotel> websiteHotelList = this.list(queryWrapper);
        return new WebsiteHotelApiBriefListVO(this.listConvertApiBriefData(websiteHotelList));
    }

    /**
     * 根据对象list获取简略VO data list
     *
     * @param websiteHotelList 对象list
     * @return 简略VO data list对象
     * @throws ManagerException 通用层异常
     */
    @Override
    public WebsiteHotelApiBriefListVO getApiBriefListVO(List<WebsiteHotel> websiteHotelList) throws ManagerException {
        return new WebsiteHotelApiBriefListVO(this.listConvertApiBriefData(websiteHotelList));
    }
}